#ifndef _MORSE_H
#define _MORSE_H
/****************************************************************************
 *
 *  Copyright:    (C) 2005 - 2017 by Dipl.-Ing. Stefan Heesch
 *                callsign: HB9TWS
 *                email:    radio@heesch.net
 *
 *  Description:  Class implementing an adaptive morse decoder
 *
 ****************************************************************************/

/****************************************************************************
 *  Includes
 ****************************************************************************/
 #if defined(ARDUINO) && ARDUINO >= 100
 #include "Arduino.h"
 #else
 #include "WProgram.h"
 #endif

/****************************************************************************
 *  Macro defintions
 ****************************************************************************/
 #define PATTERN_SIZE      8
 #define MIN_DURATION     50   
 #define DECODING_ERROR 0x7F

/****************************************************************************
 *  Type defintions
 ****************************************************************************/
 typedef struct _cw
 {
 	uint8_t  level;
	uint16_t duration;
 } cw;

typedef struct _morse
{
	char  letter;
	char  pattern[PATTERN_SIZE + 1];
} morse;

/****************************************************************************
 *  Function prototypes
 ****************************************************************************/
 char  morse_decode(cw input);
 char* morse_failed(void);
 char  morse_check(cw input);
 int   morse_speed(void);
 int   morse_timeout(void);
 void  morse_init(int speed);

/****************************************************************************
 *  End of header file
 ****************************************************************************/
#endif

